Repetier-Firmware  1.0.0
Distortion.h
Go to the documentation of this file.
1 /*
2  This file is part of Repetier-Firmware.
3 
4  Repetier-Firmware is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  Repetier-Firmware is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with Repetier-Firmware. If not, see <http://www.gnu.org/licenses/>.
16 
17 */
18 
19 #ifndef _DISTORTION_H
20 #define _DISTORTION_H
21 
22 #if DISTORTION_CORRECTION || defined(DOXYGEN)
23 
33 class Distortion {
34 public:
35  Distortion();
36  void init();
37  void enable(bool permanent = true);
38  void disable(bool permanent = true);
39  bool measure(void);
49  int32_t correct(int32_t x, int32_t y, int32_t z) const;
50  void updateDerived();
51  void reportStatus();
52  bool isEnabled() {
53  return enabled;
54  }
55  int32_t zMaxSteps() {
56  return zEnd;
57  }
58  void set(float x, float y, float z);
59  void showMatrix();
60  void resetCorrection();
61 private:
62  int matrixIndex(fast8_t x, fast8_t y) const;
63  int32_t getMatrix(int index) const;
64  void setMatrix(int32_t val, int index);
65  bool isCorner(fast8_t i, fast8_t j) const;
66  INLINE int32_t extrapolatePoint(fast8_t x1, fast8_t y1, fast8_t x2, fast8_t y2) const;
67  void extrapolateCorner(fast8_t x, fast8_t y, fast8_t dx, fast8_t dy);
68  void extrapolateCorners();
69 
70  // attributes
71 #if DRIVE_SYSTEM == DELTA
72  int32_t step;
74 #else
75  int32_t xCorrectionSteps, xOffsetSteps;
76  int32_t yCorrectionSteps, yOffsetSteps;
77 #endif
78  int32_t zStart, zEnd;
79 #if !DISTORTION_PERMANENT
81 #endif
82  bool enabled;
83 };
84 #endif //DISTORTION_CORRECTION
85 
86 #endif
int32_t getMatrix(int index) const
Definition: Distortion.cpp:140
bool isEnabled()
Definition: Distortion.h:52
int32_t zMaxSteps()
Definition: Distortion.h:55
void disable(bool permanent=true)
Definition: Distortion.cpp:113
void init()
Definition: Distortion.cpp:76
bool isCorner(fast8_t i, fast8_t j) const
Definition: Distortion.cpp:157
int32_t zEnd
Definition: Distortion.h:78
bool measure(void)
Definition: Distortion.cpp:182
Distortion()
Definition: Distortion.cpp:73
void extrapolateCorner(fast8_t x, fast8_t y, fast8_t dx, fast8_t dy)
Definition: Distortion.cpp:169
Handle distortion related stuff.
Definition: Distortion.h:33
void enable(bool permanent=true)
Definition: Distortion.cpp:104
int32_t step
Definition: Distortion.h:72
void extrapolateCorners()
Definition: Distortion.cpp:174
void reportStatus()
Definition: Distortion.cpp:126
int32_t zStart
Definition: Distortion.h:78
INLINE int32_t extrapolatePoint(fast8_t x1, fast8_t y1, fast8_t x2, fast8_t y2) const
Definition: Distortion.cpp:165
void resetCorrection()
Definition: Distortion.cpp:130
bool enabled
Definition: Distortion.h:82
int matrixIndex(fast8_t x, fast8_t y) const
Definition: Distortion.cpp:136
void showMatrix()
Definition: Distortion.cpp:421
void updateDerived()
Definition: Distortion.cpp:89
int8_t fast8_t
Definition: HAL.h:160
#define INLINE
Definition: HAL.h:37
int32_t matrix[DISTORTION_CORRECTION_POINTS *DISTORTION_CORRECTION_POINTS]
Definition: Distortion.h:80
#define DISTORTION_CORRECTION_POINTS
Definition: Configuration.h:1562
void setMatrix(int32_t val, int index)
Definition: Distortion.cpp:147
int32_t radiusCorrectionSteps
Definition: Distortion.h:73
int32_t correct(int32_t x, int32_t y, int32_t z) const
Compute distortion correction at given position.
Definition: Distortion.cpp:276